home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / lvswin31.zip / DEMO2.CPP < prev    next >
C/C++ Source or Header  |  1992-02-17  |  15KB  |  516 lines

  1. /*
  2.  *            LVS Windows
  3.  *      The Window Class System
  4.  *
  5.  *        Copyright 1992 (c), Lake View Software
  6.  *                            4321 Harborough Rd.
  7.  *                            Columbus, OH 43220
  8.  *        All rights reserved.
  9.  *
  10.  * DEMO2.CPP
  11.  */
  12.  
  13. #ifdef __TURBOC__
  14.     #include <alloc.h>
  15. #endif
  16. #include "LVSwin.hpp"
  17. #include "LVSmenu.hpp"
  18. #include "DEMO2.HPP"
  19.  
  20. /*
  21.  * Local functions
  22.  */
  23.  
  24. void Compiler_Menu ();
  25. void Linker (Options_s *opt);
  26. void Code_Generation (Options_s *opt);
  27. void Advanced_Code (Options_s *opt);
  28. int button_press (int value);
  29. void Directories (Options_s *opt);
  30. void Screen_Open ();
  31. void Debugger (Options_s *opt);
  32. void show_time ();
  33.  
  34. /*
  35.  * Global data
  36.  */
  37. Options_s options = {
  38.     0,      // map file
  39.     0,      // output exe
  40.     0,      // init segments
  41.     1,      // default libraries
  42.     0,      // graphics lib
  43.     1,      // dup symbols
  44.     1,      // no stack
  45.     1,      // case sensitive link
  46.     0,      // case sensitive exports
  47.     0,      // pack code
  48.     64L,    // pack size
  49.     32L,    // segment align
  50.     1,      // model_selected
  51.     0,      // ss_ds_selected
  52.     "",     // defines
  53.     1,      // enums as ints
  54.     0,      // word alignment
  55.     0,      // duplicate strings
  56.     0,      // unsigned chars
  57.     0,      // pre-compiled headers
  58.     1,      // float_selected
  59.     0,      // inst_set
  60.     1,      // under bars
  61.     0,      // line number
  62.     1,      // debug info in objects
  63.     1,      // fast floating point
  64.     0,      // fast huge
  65.     0,      // comdefs
  66.     0,      // far_data
  67.     32767L, // data threshold
  68.     "C:\\BC\\INCLUDE",   // Include
  69.     "C:\\BC\\LIB",       // Library
  70.     "",                // output
  71.     2,      //    source_debug_selected,
  72.     1,      //    swapping_selected,
  73.     1,      //    show_inherited,
  74.     1,      //    show_methods,
  75.     2,      //    decimal_hex_selected;
  76.     64,     //    program heap size
  77. };
  78.  
  79. void main ()
  80. {
  81.     VGA_fontload ();                // load vga fonts
  82.     VGA_setblink (W_OFF);           // allow highlighted backgrounds
  83.     Win_mouse_mode (M_FULL);        // turn mouse on
  84.     Win_setbkloop (show_time);      // Set background keyboard loop
  85.  
  86.     /*
  87.      * Open the main screen
  88.      */
  89.     Screen_Open ();
  90.  
  91.     /*
  92.      * Create the main menu
  93.      */
  94.     WinMenu m;
  95.  
  96.     m.open (3, 31, 14, 47, W_SINGLE, _BLUE|CYAN, _BLUE|WHITE);
  97.     m.set_keyattr (_BLUE|RED);
  98.     m.title (" Options ");
  99.     m.shadow ();
  100.  
  101.     m.prompt (1, 1, 1, " Compiler    ", "", 'C');
  102.     m.prompt (3, 1, 2, " Linker      ", "", 'L');
  103.     m.prompt (5, 1, 3, " Debugger    ", "", 'D');
  104.     m.prompt (7, 1, 4, " Directories ", "", 'r');
  105.     m.prompt (9, 1, 0, " Quit        ", "", 'Q');
  106.  
  107.     int choice = 1;
  108.  
  109.     while (choice && choice != W_ESCAPE)
  110.         {
  111.         choice = m.read (choice);
  112.         switch (choice)
  113.             {
  114.             case 1:
  115.                 Compiler_Menu ();
  116.                 break;
  117.  
  118.             case 2:
  119.                 Linker (&options);
  120.                 break;
  121.  
  122.             case 3:
  123.                 Debugger (&options);
  124.                 break;
  125.  
  126.             case 4:
  127.                 Directories (&options);
  128.                 break;
  129.             }
  130.         }
  131. }
  132.  
  133. void Compiler_Menu ()
  134. /*
  135.  * Compiler options menu
  136.  */
  137. {
  138.     WinMenu m;
  139.  
  140.     m.open (5, 28, 16, 48, W_SINGLE, _CYAN|BLUE, _CYAN|WHITE);
  141.     m.set_keyattr (_CYAN|RED);
  142.     m.title (" Compiler ");
  143.     m.shadow ();
  144.  
  145.     m.prompt (1, 1, 1, " Code generation ", "", 'C');
  146.     m.prompt (3, 1, 2, " Entry/Exit code ", "", 'E');
  147.     m.prompt (5, 1, 3, " C++ options     ", "", '+');
  148.     m.prompt (7, 1, 4, " Optimizations   ", "", 'O');
  149.     m.prompt (9, 1, 0, " Quit            ", "", 'Q');
  150.  
  151.     int choice = 1;
  152.  
  153.     while (choice && choice != W_ESCAPE)
  154.         {
  155.         choice = m.read (choice);
  156.         switch (choice)
  157.             {
  158.             case 1:
  159.                 Code_Generation (&options);
  160.                 break;
  161.  
  162.             case 2:
  163.                 Win_Msg ("Entry/Exit code not available");
  164.                 break;
  165.  
  166.             case 3:
  167.                 Win_Msg ("C++ options not available");
  168.                 break;
  169.  
  170.             case 4:
  171.                 Win_Msg ("Optimizations not available");
  172.                 break;
  173.             }
  174.         }
  175. }
  176.  
  177. int button_press (int value)
  178. /*
  179.  * called when the user press a button in the code_generation menu
  180.  * Same routine is used for all buttons, in this demo
  181.  */
  182. {
  183.     switch (value)
  184.         {
  185.         case 1:     // more
  186.             Advanced_Code (&options);
  187.             return 0;
  188.  
  189.         case 2:     // ok
  190.             return PGDN;
  191.  
  192.         case 3:
  193.             return ESC;
  194.  
  195.         case 4:
  196.             Win_Msg ("Sorry no help available!");
  197.             return 0;
  198.  
  199.         default:
  200.             return 0;
  201.         }
  202. }
  203.  
  204. void Directories (Options_s *opt)
  205. /*
  206.  * Read the directory options from the user
  207.  */
  208. {
  209.     WinObj w;
  210.     w.open (4, 12, 17, 67, W_SINGLE, _LGREY|BLACK, _LGREY|WHITE);
  211.     w.title ("Directories");
  212.     w.shadow ();
  213.  
  214.     w.puts (1, 1, "Include Directories");
  215.     w.puts (4, 1, "Library Directories");
  216.     w.puts (7, 1, "Output Directory");
  217.  
  218.     w.set_getattr (_GREEN|BLACK);
  219.     w.get (2, 1, opt->Include, 'U', sizeof (opt->Include) - 1);
  220.     w.get (5, 1, opt->Library, 'U', sizeof (opt->Library) - 1);
  221.     w.get (8, 1, opt->Output, 'U', sizeof (opt->Output) - 1);
  222.  
  223.     w.set_getattr (_BLUE|YELLOW);
  224.     w.get_button (11, 1, "   Ok   ", button_press, 2);
  225.     w.get_button (11, 14, " Cancel ", button_press, 3);
  226.     w.get_button (11, 27, "  Help  ", button_press, 4);
  227.  
  228.     w.read ();
  229. }
  230.  
  231. void Code_Generation (Options_s *opt)
  232. /*
  233.  * Prompt the user for code generation information
  234.  */
  235. {
  236.     char
  237.         *model_radio[] = {"Tiny   ", "Small  ", "Medium ", 
  238.                           "Compact", "Large  ", "Huge   " },
  239.         *assume_radio[] = {"Default Memory Model", 
  240.                            "Never               ",
  241.                            "Always              "};
  242.  
  243.     WinObj w;
  244.     w.open (3, 14, 21, 64, W_SINGLE, _LGREY|BLACK, _LGREY|WHITE);
  245.     w.title ("Code Generation");
  246.     w.shadow ();
  247.     w.puts (1, 1, "Model");
  248.     w.puts (1, 17, "Options");
  249.     w.puts (9, 1, "Assume SS equals DS");
  250.     w.puts (14, 1, "Defines");
  251.  
  252.     w.set_attr (_CYAN|BLACK);
  253.     w.box (2, 1, 7, 14, W_SPACES, 1);
  254.     w.box (10, 1, 12, 28, W_SPACES, 1);
  255.     w.box (2, 17, 6, 47, W_SPACES, 1);
  256.  
  257.     w.set_getattr (_CYAN|WHITE);
  258.     w.get_radio (2, 2, model_radio, opt->model_selected, 6);
  259.  
  260.     w.get_checkbox (2, 18, "Treat enums as ints     ", opt->enums);
  261.     w.get_checkbox (3, 18, "Word alignment          ", opt->word_align);
  262.     w.get_checkbox (4, 18, "Duplicate strings merged", opt->dup_strings);
  263.     w.get_checkbox (5, 18, "Unsigned characters     ", opt->unsigned_chars);
  264.     w.get_checkbox (6, 18, "Pre-compiled headers    ", opt->pre_headers);
  265.  
  266.     w.get_radio (10, 2, assume_radio, opt->ss_ds_selected, 3);
  267.     w.set_getattr (_GREEN|BLACK);
  268.     w.get (14, 9, opt->defines, 'A', sizeof (opt->defines) - 1);
  269.  
  270.     w.set_getattr (_BLUE|YELLOW);
  271.     w.get_button (16, 1,  " More...", button_press, 1);
  272.     w.get_button (16, 13, "   Ok   ", button_press, 2);
  273.     w.get_button (16, 25, " Cancel ", button_press, 3);
  274.     w.get_button (16, 37, "  Help  ", button_press, 4);
  275.  
  276.     w.read ();
  277. }
  278.  
  279. void Advanced_Code (Options_s *opt)
  280. /*
  281.  * Prompt the user for advanced code options
  282.  */
  283. {
  284.     char
  285.         *float_radio[] = {"None     ",
  286.                           "Emulation",
  287.                           "8087     ",
  288.                           "80287    "},
  289.         *inst_radio[]  = {"8088/8086",
  290.                           "80186    ",
  291.                           "80286    "};
  292.  
  293.  
  294.  
  295.     WinObj w;
  296.     w.open (5, 14, 19, 65, W_SINGLE, _LGREY|BLACK, _LGREY|WHITE);
  297.     w.title ("Advanced Code Generation");
  298.     w.shadow ();
  299.     w.puts (1, 1, "Floating Point");
  300.     w.puts (7, 1, "Instruction Set");
  301.     w.puts (1, 19, "Options");
  302.     w.puts (10, 20, "Far Data Threshold");
  303.  
  304.     w.set_attr (_CYAN|BLACK);
  305.     w.box (2, 1, 5, 16, W_SPACES, 1);
  306.     w.box (8, 1, 10, 16, W_SPACES, 1);
  307.     w.box (2, 19, 8, 48, W_SPACES, 1);
  308.  
  309.     w.set_getattr (_CYAN|WHITE);
  310.     w.get_radio (2, 2, float_radio, opt->float_selected, 4);
  311.     w.get_checkbox (2, 20, "Generate underbars     ", opt->under_bars);
  312.     w.get_checkbox (3, 20, "Line numbers debug info", opt->line_numbers);
  313.     w.get_checkbox (4, 20, "Debug info in OBJs     ", opt->debug_in_obj);
  314.     w.get_checkbox (5, 20, "Fast floating point    ", opt->fast_float);
  315.     w.get_checkbox (6, 20, "Fast huge pointers     ", opt->fast_huge);
  316.     w.get_checkbox (7, 20, "Generate COMDEFs       ", opt->comdefs);
  317.     w.get_checkbox (8, 20, "Automatic far data     ", opt->far_data);
  318.     w.get_radio (8, 2, inst_radio, opt->inst_set, 3);
  319.  
  320.     w.set_getattr (_GREEN|BLACK);
  321.     w.get (10, 40, opt->data_threshold, 5);
  322.  
  323.     w.set_getattr (_BLUE|YELLOW);
  324.     w.get_button (12, 13, "   Ok   ", button_press, 2);
  325.     w.get_button (12, 25, " Cancel ", button_press, 3);
  326.     w.get_button (12, 37, "  Help  ", button_press, 4);
  327.  
  328.     w.read ();
  329. }
  330.  
  331.  
  332. void Linker (Options_s *opt)
  333. /*
  334.  * Get linker options from the user
  335.  */
  336. {
  337.     char
  338.         *map_file_radio[] = { "Off     ", 
  339.                               "Segments", 
  340.                               "Publics ", 
  341.                               "Detailed"},
  342.         *output_radio[] = { "Standard DOS EXE", 
  343.                             "Overlaid DOS EXE", 
  344.                             "Windows EXE     ",
  345.                             "Windows DLL     "};
  346.  
  347.     WinObj w;
  348.     w.open (3, 11, 20, 68, W_SINGLE, _LGREY|BLACK, _LGREY|WHITE);
  349.     w.title ("Linker");
  350.     w.shadow ();
  351.     w.puts (1, 1, "Map File");
  352.     w.puts (7, 1, "Output");
  353.     w.puts (1, 27, "Options");
  354.     w.puts (12, 28, "Code Pack Size");
  355.     w.puts (13, 28, "Segment Alignment");
  356.     w.set_attr (_CYAN|BLACK);
  357.     w.box (2, 1, 5, 17, W_SPACES, 1);
  358.     w.box (8, 1, 11, 22, W_SPACES, 1);
  359.     w.box (2, 27, 9, 54, W_SPACES, 1);
  360.  
  361.     w.set_getattr (_CYAN|WHITE);
  362.     w.get_radio (2, 2, map_file_radio, opt->map_file_selected, 4);
  363.     w.get_radio (8, 2, output_radio, opt->lnk_output_selected, 4);
  364.  
  365.     w.get_checkbox (2, 28, "Initialize Segments   ", opt->init_segments);
  366.     w.get_checkbox (3, 28, "Default Libraries     ", opt->default_libs);
  367.     w.get_checkbox (4, 28, "Graphics Library      ", opt->graphics_lib);
  368.     w.get_checkbox (5, 28, "Warn duplicate symbols", opt->dup_symbols);
  369.     w.get_checkbox (6, 28, "no Stack warning      ", opt->no_stack);
  370.     w.get_checkbox (7, 28, "Case Sensitive Link   ", opt->case_link);
  371.     w.get_checkbox (8, 28, "Case Sensitive Exports", opt->case_exports);
  372.     w.get_checkbox (9, 28, "Pack code segments    ", opt->pack_code);
  373.  
  374.     w.set_getattr (_GREEN|BLACK);
  375.     w.get (12, 46, opt->pack_size, 5);
  376.     w.get (13, 46, opt->segment_align, 5);
  377.  
  378.     w.set_getattr (_BLUE|YELLOW);
  379.     w.get_button (15, 1, "   Ok   ", button_press, 2);
  380.     w.get_button (15, 14, " Cancel ", button_press, 3);
  381.     w.get_button (15, 27, "  Help  ", button_press, 4);
  382.  
  383.     w.read ();
  384. }
  385.  
  386. void Debugger (Options_s *opt)
  387. /*
  388.  * Get debuger options from the user
  389.  */
  390. {
  391.     char
  392.         *source_radio[] =   { "On        ",
  393.                               "Standalone",
  394.                               "None      "},
  395.         *display_radio[]=   { "None  ",
  396.                               "Smart ",
  397.                               "Always"},
  398.         *decimal_radio[] =  { "Show decimal",
  399.                               "Show hex    ",
  400.                               "Show both   "};
  401.  
  402.     WinObj w;
  403.     w.open (3, 14, 16, 66, W_SINGLE, _LGREY|BLACK, _LGREY|WHITE);
  404.     w.title ("Debugger");
  405.     w.shadow ();
  406.     w.puts (1, 1, "Source Debugging");
  407.     w.puts (6, 1, "Display Swapping");
  408.     w.puts (1, 19, "Inspectors");
  409.     w.puts (9, 19, "Program Heap Size");
  410.     w.puts (10,27, "K bytes");
  411.  
  412.     w.set_attr (_CYAN|BLACK);
  413.     w.box (2, 1, 4, 16, W_SPACES, 1);
  414.     w.box (7, 1, 9, 16, W_SPACES, 1);
  415.     w.box (2, 19, 3, 38, W_SPACES, 1);
  416.     w.box (5, 19, 7, 38, W_SPACES, 1);
  417.  
  418.     w.set_getattr (_CYAN|WHITE);
  419.     w.get_radio (2, 2, source_radio, opt->source_debug_selected, 3);
  420.     w.get_radio (7, 2, display_radio, opt->swapping_selected, 3);
  421.  
  422.     w.get_checkbox (2, 20, "Show inherited", opt->show_inherited);
  423.     w.get_checkbox (3, 20, "Show methods", opt->show_methods);
  424.  
  425.     w.get_radio (5, 20, decimal_radio, opt->decimal_hex_selected, 3);
  426.  
  427.     w.set_getattr (_GREEN|BLACK);
  428.     w.get (10, 19, opt->program_heap, 4);
  429.  
  430.     w.set_getattr (_BLUE|YELLOW);
  431.     w.get_button (2, 42, "   Ok   ", button_press, 2);
  432.     w.get_button (5, 42, " Cancel ", button_press, 3);
  433.     w.get_button (8, 42, "  Help  ", button_press, 4);
  434.  
  435.     w.read ();
  436. }
  437.  
  438. void Screen_Open ()
  439. {
  440.     /*
  441.      * Open a window to cover the screen
  442.      */
  443.     static WinObj Main;
  444.     int bkground = _BLACK;
  445.  
  446.     if (!VGA_blinkstate ())
  447.         bkground = _DGREY;
  448.  
  449.     Main.open (0, 0, 24, 79, W_NOBORDER, bkground|LGREY);
  450.  
  451.     for (int x = 0; x < 54; x++)
  452.         Main.printf ("- LVS Windows -- Lake View Software -");
  453.  
  454.     /*
  455.      * Title the top of the screen
  456.      */
  457.  
  458.     static WinObj title_win;
  459.  
  460.     bkground = _LGREY|BLUE;
  461.     if (!VGA_blinkstate ())
  462.         bkground = _WHITE|BLUE;
  463.         
  464.     title_win.open (0, 0, 0, 79, W_NOBORDER, bkground);
  465.     title_win.center (0, "Lake View Software Demo2");
  466.  
  467.  
  468.     /*
  469.      * Display the logo
  470.      */
  471.     static WinObj logo;
  472.  
  473.     bkground = _BLACK;
  474.  
  475.     if (!VGA_blinkstate ())
  476.         bkground = _DGREY;
  477.  
  478.     logo.open (19, 19, 22, 59, W_DOUSIN, 
  479.                bkground|WHITE, bkground|YELLOW);
  480.     logo.shadow ();
  481.  
  482.     logo.title (logo.get_version ());
  483.     logo.center (0, "The C++ window class system");
  484.     logo.center (1,"Copyright (c) 1992");
  485. }
  486.  
  487. static WinObj clock_win;
  488.  
  489. void show_time ()
  490. {
  491.     struct Win_time_s t;
  492.     static unsigned char hold;
  493.  
  494.     if (!clock_win.is_open())       // open clock window once
  495.         {
  496.         clock_win.open (0, 0, 0, 79, W_NOBORDER, _LGREY|BLUE);
  497.         clock_win.center (0, "Lake View Software");
  498.         }
  499.  
  500.     /*
  501.      * First show the clock
  502.      */
  503.  
  504.     Win_gettime (&t);
  505.  
  506.     if (hold != t.sec) 
  507.         {
  508.         hold = t.sec;
  509.         clock_win.printf (0, 1, "%02d:%02d:%02d", t.hour, t.min, t.sec);
  510.         #ifdef __TURBOC__
  511.         clock_win.printf (0, 73, "%6ld", (long )coreleft ());  // show free mem
  512.         #endif
  513.         }
  514. }
  515.  
  516.